from dash import html

def get_user_info(user_info: dict) -> dict[str, str]:
    ret_val = {
            "性别": "N/A", 
            "出生日期": "N/A", 
            "教育": "N/A",
            "工作": "N/A",
            "收入": "N/A",
            "省份": "N/A",
            "城市": "N/A",
            "聚落类型": "N/A"
        }
    if len(user_info) != 0:
        ret_val["性别"] = str(user_info['GENDER'].values[0])
        ret_val["出生日期"] = str(int(user_info['BIRTHDAY'].values[0]))
        ret_val["教育"] = str(user_info['EDU'].values[0])
        ret_val["工作"] = str(user_info['JOB'].values[0])
        ret_val["收入"] = str(user_info['INCOME'].values[0])
        ret_val["省份"] = str(user_info['PROVINCE'].values[0])
        ret_val["城市"] = str(user_info['CITY'].values[0])
        ret_val["聚落类型"] = str(user_info['ISCITY'].values[0])
    return ret_val

def user_info(user_info: dict) -> html.Div:
    info = get_user_info(user_info)
    user_info_div = html.Div([
        html.Table([
            html.Tr([html.Td("性别"), html.Td(info['性别'])]),
            html.Tr([html.Td("出生日期"), html.Td(info['出生日期'])]),
            html.Tr([html.Td("教育"), html.Td(info['教育'])]),
            html.Tr([html.Td("工作"), html.Td(info['工作'])]),
            html.Tr([html.Td("收入"), html.Td(info['收入'])]),
            html.Tr([html.Td("省份"), html.Td(info['省份'])]),
            html.Tr([html.Td("城市"), html.Td(info['城市'])]),
            html.Tr([html.Td("聚落类型"), html.Td(info['聚落类型'])]),
        ], style={'width': '80%', 'display': 'table', 'tableLayout': 'fixed'})
    ])
    return user_info_div